package top.haijunit.work.scheduler;

import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import top.haijunit.work.service.WebSocketHandler;

/**
 * 【说明类功能】
 *
 * @author zhanghaijun
 * @since 2024-09-20
 */
@Component
@RequiredArgsConstructor(onConstructor_ = @__(@Autowired))
public class HeartbeatScheduler {

    private final WebSocketHandler myWebSocketHandler;

    /**
     * 每隔30秒发送一次心跳
     */
    @Scheduled(fixedRate = 30000)
    public void sendHeartbeat() {
        myWebSocketHandler.sendHeartbeat();
    }
}
